const TOKEN_NAME = 'hm-news-token'
const CHANNEL_NAME = 'hm-news-channel'
const HISTORY_NAME = 'hm-news-history'

// 存储历史记录
export const setStoregeHistory = history => {
  localStorage.setItem(HISTORY_NAME, JSON.stringify(history))
}

// 获取历史记录
export const getStoreHistory = () => {
  return JSON.parse(localStorage.getItem(HISTORY_NAME)) || []
}

// 存储频道
export const setStoregeChannel = channel => {
  localStorage.setItem(CHANNEL_NAME, JSON.stringify(channel))
}
// 获取频道
export const getStoreChannel = () => {
  return JSON.parse(localStorage.getItem(CHANNEL_NAME))
}

// 获取token
export const getStorageToken = () => {
  return JSON.parse(localStorage.getItem(TOKEN_NAME)) || {}
}

// 储存token
export const setStorageToken = token => {
  localStorage.setItem(TOKEN_NAME, JSON.stringify(token))
}

// 删除token
export const removeStorageToken = () => {
  localStorage.removeItem(TOKEN_NAME)
}
